

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map.Entry;

public class ItemList
{
	// Storage for an arbitrary number of details.
	private HashMap <String,Item> itemList;

	/**
	 * Perform any initialization .
	 */
	public ItemList()
	{
		itemList = new HashMap<String,Item>() ;
	}

	/**
	 * Add a new set of details to the list
	 * @param details The details of the staff
	 */
	public void addDetails(String id,Item details) 
	{
		itemList.put(id,details);
	}

	public boolean hasItem() {
		return itemList.size() != 0;
	}

	public Mouse getNextItem() {
		Mouse mouse = null;
		Item item =  itemList.remove(0);

		if (item instanceof Mouse){
			mouse=(Mouse) item;}


		return mouse;

	}

	public void hashPrint(){
		System.out.println("Retrieving all values from the HashMap");

		Iterator<Entry<String, Item>> iterator = itemList.entrySet().iterator();
		while(iterator.hasNext()){        

			System.out.println(iterator.next());

		}

	}


	public Item getItembyId(String id){
		Item m=itemList.get(id);
		return m;
	}

	public boolean keyExists(String id){
		boolean blnExists = itemList.containsKey(id);
		if (blnExists)
			System.out.println("Item id "+id+" already exists in HashMap");
		return blnExists;
	}
}
